<?php

namespace app\admin\model\course;

use basic\BaseModel;
use services\UtilService;
use traits\ModelTrait;

/**
 * 课程的分类
 * Class CourseCategory
 * @package app\admin\model\course
 */
class CourseGroup extends BaseModel
{
    use ModelTrait;

    /**
     * 主键
     * @var string
     */
    protected $pk = "id";

    /**
     * 模型名称
     * @var string
     */
    protected $name = "course_group";

    /**
     * @title 分级排序列表 【只需要一级分类】
     * @param null $model
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getTierList($model = null)
    {
        if ($model === null) $model = new self();
        return $model->order('sort desc,id desc')->select()->toArray();
    }

    /**
     * @param array $where
     */
    public static function groupList(array $where)
    {
        $data = ($data = self::systemPage($where, true)->page((int)$where['page'], (int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
    }
}